<template>
  <div class="career-plan">
    <div class="heading">
      <div class="title">职业规划</div>
      <div class="info">智能规划，过好职业生涯</div>
    </div>

    <div class="tag-group">
      <div
        v-for="(item, index) in tags"
        :key="index"
        :class="['tag', curr === item.id && 'active']"
        @click="onSelect(item)"
      >{{ item.name }}</div>
    </div>

    <div class="content">
      <div class="reason">
        <div class="info">
          <div class="title">立即开启职业规划的黄金人生</div>
          <div class="desc">机会留给有准备的人</div>
        </div>
        <div class="change">
          换一换
          <van-icon name="replay" :style="{ marginLeft: '4px' }" />
        </div>
      </div>

      <div class="article">
        <row-image
          v-for="item in articles"
          :style="{ margin: 0 }"
          :border="false"
          :key="item.id"
          :title="item.title"
          :desc="item.type"
          :cover="item.cover"
          :star="Number(item.star)"
          :read="item.read"
        />
      </div>

      <div class="action">
        <div class="button">
          <van-icon name="diamond-o" size="18" :style="{ marginRight: '4px' }" />
          定制我的职业生涯
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { Icon } from 'vant'
import RowImage from '@/components/Product/RowImage'

Vue.use(Icon)

const tags = [
  { id: 0, name: '启动配置' },
  { id: 1, name: '定期回顾' }
]

Object.freeze(tags)

export default {
  components: {
    RowImage
  },

  data() {
    return {
      curr: -1,
      articles: [
        {
          id: 0,
          cover: '',
          title: '职业规划初始课程',
          read: '3.8',
          star: '4',
          type: '就业 ｜ 应届'
        },
        {
          id: 1,
          cover: '',
          title: '万事开头难，如何选择行业',
          read: '3.8',
          star: '4',
          type: '就业 ｜ 应届'
        }
      ],
      tags
    }
  },

  methods: {
    onSelect(e) {
      const { id } = e
      this.curr = this.curr === id ? -1 : id
    }
  }
}
</script>

<style lang="less" scoped>
.career-plan {
  .heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 17px;

    .title {
      font-size: 18px;
      color: #222222;
      font-weight: 500;
    }

    .info {
      font-size: 13px;
      color: #999999;
    }
  }

  .tag-group {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 0 12px;

    .tag {
      padding: 5px 12px;
      border-radius: 5px;
      background-color: #e9e9e9;
      color: #444444;
      font-size: 14px;
      font-weight: 300;
      margin: 5px 8px;
      transition: 300ms;
    }

    .active {
      font-weight: normal;
      background-color: #4586ff;
      color: #ffffff;
    }
  }

  .content {
    background-color: #ffffff;
    margin: 0 17px;
    margin-top: 15px;
    padding: 17px 13px;
    border-radius: 5px;
    box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.1);

    .reason {
      background-color: #eef2f9;
      border-radius: 5px;
      align-items: center;
      display: flex;
      position: relative;
      padding: 12.5px 13px;
      justify-content: space-between;

      .info {
        display: flex;
        flex-flow: column;
        justify-content: space-between;

        .title {
          font-size: 16px;
          font-weight: 500;
          color: #3478f6;
        }

        .desc {
          font-size: 12px;
          color: #666666;
          margin-top: 6px;
        }
      }

      .change {
        display: flex;
        align-items: center;
        font-size: 12px;
        color: #b7c4dc;
      }
    }

    .article {
      margin-top: 16px
    }

    .action {
      display: flex;
      justify-content: center;
      margin-top: 10.5px;

      .button {
        padding: 12.5px 0;
        border-radius: 5px;
        color: #ffffff;
        background-color: #3478F6;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        width: 100%;
      }
    }
  }
}
</style>